<template>
  <el-card class="filter-card" shadow="never">
    <el-form :model="queryParams" inline>
      <el-form-item label="商品名称">
        <el-input
          v-model="queryParams.productName"
          placeholder="输入商品名称"
          clearable
          style="width: 200px"
          class="input-field"
        />
      </el-form-item>
      
      <el-form-item label="SKU">
        <el-input
          v-model="queryParams.sku"
          placeholder="输入SKU"
          clearable
          style="width: 150px"
          class="input-field"
        />
      </el-form-item>
      
      <el-form-item label="状态">
        <el-select v-model="queryParams.status" clearable placeholder="全部状态" class="form-item-width select-field">
          <el-option label="在售" value="active" />
          <el-option label="停售" value="inactive" />
          <el-option label="缺货" value="outofstock" />
        </el-select>
      </el-form-item>
      
      <el-form-item>
        <el-button type="primary" :icon="Search" @click="handleSearch" class="search-btn">
          查询
        </el-button>
        <el-button :icon="Refresh" @click="handleReset" class="reset-btn">
          重置
        </el-button>
        <el-button 
          link
          :icon="SetUp" 
          @click="showAdvancedFilter = !showAdvancedFilter"
          class="advanced-btn"
        >
          高级筛选
        </el-button>
      </el-form-item>
    </el-form>

    <!-- 高级筛选 -->
    <el-collapse-transition>
      <div v-show="showAdvancedFilter" class="advanced-filter">
        <el-divider content-position="left">高级筛选</el-divider>
        <el-form :model="queryParams" inline>
          <el-form-item label="最低库存">
            <el-input-number
              v-model="queryParams.minStock"
              :min="0"
              placeholder="最低库存"
              style="width: 120px"
              class="input-number-field"
            />
          </el-form-item>
          
          <el-form-item label="最高库存">
            <el-input-number
              v-model="queryParams.maxStock"
              :min="0"
              placeholder="最高库存"
              style="width: 120px"
              class="input-number-field"
            />
          </el-form-item>
          
          <el-form-item label="更新时间">
            <el-date-picker
              v-model="queryParams.updateDateRange"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="YYYY-MM-DD"
              class="date-picker-field"
            />
          </el-form-item>
        </el-form>
      </div>
    </el-collapse-transition>
  </el-card>
</template>

<script setup lang="ts">
import { ref, defineProps, defineEmits } from 'vue'
import { Search, Refresh, SetUp } from '@element-plus/icons-vue'

const showAdvancedFilter = ref(false)

// 定义查询参数接口
interface QueryParams {
  productName: string
  sku: string
  status: string
  minStock: number | undefined
  maxStock: number | undefined
  updateDateRange: string[]
  page: number
  limit: number
}

const props = defineProps<{
  queryParams: QueryParams
}>()

const emit = defineEmits<{
  (e: 'search'): void
  (e: 'reset'): void
}>()

const handleSearch = () => {
  emit('search')
}

const handleReset = () => {
  emit('reset')
}
</script>

<style scoped>
.filter-card {
  margin-bottom: 20px;
  transition: all 0.3s ease;
}

.filter-card:hover {
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.advanced-filter {
  margin-top: 16px;
}

.advanced-filter :deep(.el-divider) {
  margin: 16px 0;
}

/* 表单元素悬停效果 */
.input-field:hover,
.select-field:hover,
.input-number-field:hover,
.date-picker-field:hover {
  transform: translateY(-1px);
  transition: all 0.3s ease;
}

/* 按钮动画效果 */
.search-btn,
.reset-btn,
.advanced-btn {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.search-btn:hover,
.reset-btn:hover,
.advanced-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.search-btn:active,
.reset-btn:active,
.advanced-btn:active {
  transform: translateY(0);
}

.search-btn::after,
.reset-btn::after,
.advanced-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.search-btn:active::after,
.reset-btn:active::after,
.advanced-btn:active::after {
  width: 300px;
  height: 300px;
}

/* 查询按钮特殊样式 */
.search-btn {
  background-color: #409eff;
  border-color: #409eff;
  color: white;
}

.search-btn:hover {
  background-color: #66b1ff;
  border-color: #66b1ff;
}

/* 重置按钮特殊样式 */
.reset-btn {
  background-color: #909399;
  border-color: #909399;
  color: white;
}

.reset-btn:hover {
  background-color: #a6a9ad;
  border-color: #a6a9ad;
}

/* 高级筛选按钮特殊样式 */
.advanced-btn {
  color: #409eff;
}

.advanced-btn:hover {
  color: #66b1ff;
}
</style>